package cn.jbolt.ai.resource.vdb;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


public enum VDBType {

    TENCENT("TENCENT", "腾讯", new ConfigItem[]{

    }),

    MILVUS("MILVUS", "MILVUS", new ConfigItem[]{

    });


    private String name;

    private String sn;

    private ConfigItem[] configItems;

    /**
     * 根据sn查找对应的模型类型
     * @param sn
     * @return
     */
    public static VDBType getBySn(String sn) {
        if (sn == null) {
            throw new IllegalArgumentException("VDB sn 不能为 null");
        }
        return Arrays.stream(values())
                .filter(type -> type.getSn().equals(sn))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("未找到匹配的 VDB : " + sn));
    }



    VDBType(String sn, String name, ConfigItem[] configItems) {
        this.sn = sn;
        this.name = name;
        this.configItems = configItems;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public String getName() {
        return name;
    }

    public ConfigItem[] getConfigItems() {
        return configItems;
    }


    @JsonInclude(JsonInclude.Include.NON_NULL)
    private static class ConfigItem {


    }


    /**
     * 将枚举转换为所需的列表格式
     *
     * @return
     */
    public static List<Map<String, Object>> list() {
        return Arrays.asList(values()).stream().map(modelType -> {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("sn", modelType.sn);
            map.put("name", modelType.name);
//            map.put("configItems", modelType.getConfigItems());
            return map;
        }).collect(Collectors.toList());
    }


}
